﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraTreeList;
using DevExpress.XtraTreeList.Nodes;
using HuaCheng.Controller;
using HuaCheng.Model;
using System.Text.RegularExpressions;
using HuaCheng.CommonClass;

namespace HuaCheng.Views
{
    /// <summary>
    /// 斜坡工况页
    /// </summary>
    public partial class SlopeCondition : Form
    {
        //右键菜单被触发的节点
        TreeListNode currentNode = null;
        //上一次编辑的斜坡工况表
        DataTable dtSlope;
        //定义获得斜坡工况数据的委托和事件
        public delegate void GetSlopeParams(DataTable dt, float rate, string mode,string path, string curOrPowUnit,string timeUnit);
        public event GetSlopeParams GetBackSlopParams;
        //为去除自带右键菜单，只允许输入数字
        RepositoryItem TextEdit = new RepositoryItemTextEdit();
        RepositoryItem TextTimeEdit = new RepositoryItemTextEdit();
        RepositoryItem TextNoEdit = new RepositoryItemTextEdit();
        public void OnGetBackSlopePath(DataTable dt, float rate, string mode, string path, string curOrPowUnit, string timeUnit)
        {
            if (GetBackSlopParams != null)
            {
                GetBackSlopParams(dt, rate,mode, path,curOrPowUnit,timeUnit);
            }
        }
        public SlopeCondition(DataTable dt, string mode, float mag, string path, string curOrPowUnit, string timeUnit)
        {
            InitializeComponent();
            dtSlope = dt;
            this.tbRate.Text = mag.ToString();
            this.cbxMode.SelectedItem = mode;//模式
            this.tbPath.Text = path;
            if (curOrPowUnit == "A" || curOrPowUnit == "W")//如果初次打开编辑默认为A或者上一次编辑的值为A
                this.cbxCurrent.SelectedIndex = 0;//电流单位为A
            else
                this.cbxCurrent.SelectedIndex = 1;//电流单位为mA
            if (timeUnit == "s")//如果初次打开编辑默认为s或者上一次编辑的值为s
                this.cbxTime.SelectedIndex = 0;//时间单位为s
            else
                this.cbxTime.SelectedIndex = 1;//时间单位为ms
            if (dt.Rows.Count != 0)
            {
                DtToTreeList(dt, curOrPowUnit, timeUnit);//加载工况表
            }
            else
            {
                LoadEmpty();
            }
            TextEdit.MouseDown += tlSlopeStep_MouseDown;
            TextEdit.KeyPress += CellEdit_KeyPress;
            TextEdit.Leave += CellEdit_Leave;
            TextTimeEdit.MouseDown += tlSlopeStep_MouseDown;
            TextTimeEdit.KeyPress += txtTime_KeyPress;
            TextTimeEdit.Leave += CellEdit_Leave;
            TextNoEdit.ReadOnly = true;
            TextNoEdit.MouseDown += tlSlopeStep_MouseDown;
        }
        /// <summary>
        /// 设置单元格中只允许输入数字，‘.’，退格
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CellEdit_KeyPress(object sender, KeyPressEventArgs e)
        {
            //允许输入数字、小数点、删除键和负号  
            if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8 && e.KeyChar != (char)('.') && e.KeyChar != (char)('-'))
            {
                e.Handled = true;
            }
            if (e.KeyChar == (char)('-'))
            {
                if (((TextEdit)sender).Text != "")
                {
                    e.Handled = true;
                }
            }
            //小数点只能输入一次  
            if (e.KeyChar == (char)('.') && ((TextEdit)sender).Text.IndexOf('.') != -1)
            {
                e.Handled = true;
            }
            //第一位不能为小数点  
            if (e.KeyChar == (char)('.') && ((TextEdit)sender).Text == "")
            {
                e.Handled = true;
            }
            //第一位是负号，第二位不能为小数点
            if (((TextEdit)sender).Text == "-" && e.KeyChar == (char)('.'))
            {
                e.Handled = true;
            }
            //第一位是-，第二位是0时，第三位为小数点或者退格
            if (((TextEdit)sender).Text == "-0" && e.KeyChar != (char)('.') && e.KeyChar != 8)
            {
                e.Handled = true;
            }
            //小数点后最多4位小数
            if (e.KeyChar != '\b' && (((TextEdit)sender).SelectionStart) > (((TextEdit)sender).Text.LastIndexOf('.')) + 4 && ((TextEdit)sender).Text.IndexOf(".") >= 0)
            {
                e.Handled = true;
            }
        }
        /// <summary>
        /// 单元格中的多个0校验
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CellEdit_Leave(object sender, System.EventArgs e)
        {
            if (Convert.ToString(((TextEdit)sender).Text).StartsWith("0"))
            {
                if (Regex.Matches(((TextEdit)sender).Text, @"0").Count + Regex.Matches(((TextEdit)sender).Text, @"\.").Count != ((TextEdit)sender).Text.Length)
                {
                    if (!Convert.ToString(((TextEdit)sender).Text).StartsWith("0."))
                    {
                        if (Regex.IsMatch(((TextEdit)sender).Text, @"^0+\."))
                        {
                            Regex reg = new Regex(@"^0+");
                            tlSlopeStep.SetFocusedValue(reg.Replace(((TextEdit)sender).Text, "0"));
                        }
                        else
                        {
                            Regex reg = new Regex(@"^0+");
                            tlSlopeStep.SetFocusedValue(reg.Replace(((TextEdit)sender).Text, ""));
                        }
                    }
                }
                else
                {
                    tlSlopeStep.SetFocusedValue("0");
                }
            }
        }
        /// <summary>
        /// 时间列的校验
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtTime_KeyPress(object sender, KeyPressEventArgs e)
        {
            //允许输入数字、小数点、删除键
            if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8 && e.KeyChar != (char)('.'))
            {
                e.Handled = true;
            }
            //小数点只能输入一次  
            if (e.KeyChar == (char)('.') && ((TextEdit)sender).Text.IndexOf('.') != -1)
            {
                e.Handled = true;
            }
            //第一位不能为小数点  
            if (e.KeyChar == (char)('.') && ((TextEdit)sender).Text == "")
            {
                e.Handled = true;
            }
            //小数点后最多4位小数
            if (e.KeyChar != '\b' && (((TextEdit)sender).SelectionStart) > (((TextEdit)sender).Text.LastIndexOf('.')) + 4 && ((TextEdit)sender).Text.IndexOf(".") >= 0)
            {
                e.Handled = true;
            }
        }
        /// <summary>
        /// 浏览按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            openFileDlg.Filter = "All|*.*";
            openFileDlg.RestoreDirectory = true;
            if (openFileDlg.ShowDialog() == DialogResult.OK)
            {
                List<SlopeStep> slopeList = ExcelControl.GetSlopeList(openFileDlg.FileName);
                tlSlopeStep = SlopeControl.SetTreeListBySlopeList(slopeList, tlSlopeStep);
                tbPath.Text = openFileDlg.FileName;
            }
        }
        /// <summary>
        /// 取消按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        /// <summary>
        /// 初始化空表格
        /// </summary>
        private void LoadEmpty()
        {
            TreeListNode tmpNode = tlSlopeStep.Nodes.Add();
            tmpNode["SerialNum"] = tlSlopeStep.Nodes.Count;
            tlSlopeStep.FocusedNode = tmpNode;
        }
        /// <summary>
        /// 模式选择
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cbxMode_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbxMode.SelectedItem.ToString() == "电流")
            {
                lblCurrent.Text = ResourceCulture.GetString("CurUnit") + ":";
                cbxCurrent.Items.Clear();
                cbxCurrent.Items.AddRange(new object[]{
                    "A",
                    "mA"
                });
                cbxCurrent.SelectedItem = "A";
                tlSlopeStep.Columns[1].Caption = ResourceCulture.GetString("lblCurrentText") + "1(A）";
                tlSlopeStep.Columns[3].Caption = ResourceCulture.GetString("lblCurrentText") + "2(A）";
            }
            else if (cbxMode.SelectedItem.ToString() == "功率")
            {
                lblCurrent.Text = ResourceCulture.GetString("PowerUnit") + ":";
                cbxCurrent.Items.Clear();
                cbxCurrent.Items.AddRange(new object[]{
                    "W",
                    "mW"
                });
                cbxCurrent.SelectedItem = "W";
                tlSlopeStep.Columns[1].Caption = ResourceCulture.GetString("Power") + "1(W）";
                tlSlopeStep.Columns[3].Caption = ResourceCulture.GetString("Power") + "2(W）";
            }
        }
        /// <summary>
        /// 保存按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            savefileDlg.Filter = "All|*.*|Excel文件|*.xlsx;*.xls;";
            savefileDlg.RestoreDirectory = true;
            if (savefileDlg.ShowDialog() == DialogResult.OK)
            {
                List<SlopeStep> slopeList = SlopeControl.GetSlopeStepByTreeList(tlSlopeStep);
                ExcelControl.SetSlopeDataToExcel(slopeList, savefileDlg.FileName);
                if (IndexPage.language == "en-US")
                {
                    MessageBox.Show("Success！", "Tip", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show("已成功导出！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }

        private void tlSlopeStep_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                tlSlopeStep.ContextMenuStrip = null;
                TreeListHitInfo hInfo = tlSlopeStep.CalcHitInfo(new System.Drawing.Point(e.X, e.Y));
                currentNode = hInfo.Node;
                tlSlopeStep.FocusedNode = currentNode;
                if (currentNode != null)
                {
                    if (currentNode["SerialNum"] != null)
                    {
                        tlSlopeStep.ContextMenuStrip = cmsNode;
                    }
                }
            }
        }

        private void tlSlopeStep_CustomNodeCellEdit(object sender, DevExpress.XtraTreeList.GetCustomNodeCellEditEventArgs e)
        {
            switch (e.Column.Name)
            {
                case "tlTime":
                case "tlSlope":
                    {
                        e.RepositoryItem = TextTimeEdit;
                    } break;
                case "tlSerialNum":
                    {
                        e.RepositoryItem = TextNoEdit;
                    } break;
                default:
                    {
                        e.RepositoryItem = TextEdit;
                    } break;
            }
        }
        /// <summary>
        /// 倍率键盘输入监听事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tbRate_KeyPress(object sender, KeyPressEventArgs e)
        {
            //允许输入数字、小数点、删除键
            if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8 && e.KeyChar != (char)('.'))
            {
                e.Handled = true;
            }
            //小数点只能输入一次  
            if (e.KeyChar == (char)('.') && ((TextBox)sender).Text.IndexOf('.') != -1)
            {
                e.Handled = true;
            }
            //第一位不能为小数点  
            if (e.KeyChar == (char)('.') && ((TextBox)sender).Text == "")
            {
                e.Handled = true;
            }
            //小数点后最多4位小数
            if (e.KeyChar != '\b' && (((TextBox)sender).SelectionStart) > (((TextBox)sender).Text.LastIndexOf('.')) + 4 && ((TextBox)sender).Text.IndexOf(".") >= 0)
            {
                e.Handled = true;
            }
        }
        /// <summary>
        /// 倍率的多个0校验
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tbRate_Leave(object sender, System.EventArgs e)
        {
            if (Convert.ToString(((TextBox)sender).Text).StartsWith("0"))
            {
                if (Regex.Matches(((TextBox)sender).Text, @"0").Count + Regex.Matches(((TextBox)sender).Text, @"\.").Count != ((TextBox)sender).Text.Length)
                {
                    if (!Convert.ToString(((TextBox)sender).Text).StartsWith("0."))
                    {
                        if (Regex.IsMatch(((TextBox)sender).Text, @"^0+\."))
                        {
                            Regex reg = new Regex(@"^0+");
                            ((TextBox)sender).Text = reg.Replace(((TextBox)sender).Text, "0");
                        }
                        else
                        {
                            Regex reg = new Regex(@"^0+");
                            ((TextBox)sender).Text = reg.Replace(((TextBox)sender).Text, "");
                        }
                    }
                }
                else
                {
                    ((TextBox)sender).Text = "0";
                }
            }
        }
        /// <summary>
        /// 确定按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            DataTable dt = TreelistToDt();
            if (dt.Rows.Count > 0)
            {
                float rate = 1.0f;//倍率
                string mode = "电流模式";
                string path="";
                string curOrPowUnit = "A";//默认为电流单位A
                string timeUnit = "s";//默认时间为s
                if (tbRate.Text != "")
                {
                    rate = float.Parse(tbRate.Text);
                }
                if (cbxMode.Text != "")
                {
                    mode = cbxMode.Text;
                }
                if (tbPath.Text != "")
                {
                    path = tbPath.Text;
                }
                //电流或功率单位
                if (tlSlopeStep.Columns[1].Caption.Contains("mA"))
                {
                    curOrPowUnit = "mA";
                }
                else if (tlSlopeStep.Columns[1].Caption.Contains("mW"))
                {
                    curOrPowUnit = "mW";
                }
                else if (tlSlopeStep.Columns[1].Caption.Contains("W"))
                {
                    curOrPowUnit = "W";
                }
                //时间单位
                if (cbxTime.SelectedIndex == 1)
                {
                    timeUnit = "ms";
                }
                OnGetBackSlopePath(dt, rate, mode,path,curOrPowUnit,timeUnit);
                this.Close();
            }
            else
            {
                if (IndexPage.language == "en-US")
                {
                    MessageBox.Show("Table empty！");
                }
                else
                {
                    MessageBox.Show("斜坡工况数据表不能为空！");
                }
            }
        }
        /// <summary>
        /// treelist转斜坡DataTable工况表并且转换成默认单位对应的数据
        /// </summary>
        /// <returns></returns>
        public DataTable TreelistToDt()
        {
            DataTable dt = new DataTable();
            string strMode = cbxMode.SelectedItem.ToString();
            dt.Columns.Add(strMode+"幅值1");
            dt.Columns.Add("斜率");
            dt.Columns.Add(strMode+"幅值2");
            dt.Columns.Add("时间");
            float magnification = 1.0f;
            if (tbRate.Text != "")
            {
                magnification = float.Parse(tbRate.Text.ToString());
            }
            for (int i = 0; i < tlSlopeStep.Nodes.Count; i++)
            {
                DataRow row = dt.NewRow();
                //电流幅值1
                if (tlSlopeStep.Nodes[i]["CurrAmp1"] != null)
                {
                    if(tlSlopeStep.Nodes[i]["CurrAmp1"].ToString() != "")
                    {
                        //不是默认单位则转换数据
                        if (cbxCurrent.Text != "A" && cbxCurrent.Text != "W")
                        {
                            row[strMode + "幅值1"] = ((float.Parse((tlSlopeStep.Nodes[i]["CurrAmp1"]).ToString())) * float.Parse(tbRate.Text) / 1000).ToString();
                        }
                        //默认单位直接存数据
                        else
                        {
                            row[strMode + "幅值1"] = float.Parse(tlSlopeStep.Nodes[i]["CurrAmp1"].ToString()) * float.Parse(tbRate.Text);
                        }
                    }
                    //“”则存0
                    else
                    {
                        row[strMode + "幅值1"] = "0";
                    }
                }
                //“”则存0
                else
                {
                    row[strMode + "幅值1"] = "0";
                }
                //斜率
                if (tlSlopeStep.Nodes[i]["Slope"] != null)
                {
                    if (tlSlopeStep.Nodes[i]["Slope"].ToString() != "")
                    {
                        row["斜率"] = tlSlopeStep.Nodes[i]["Slope"];
                    }
                    //“”则存0
                    else
                    {
                        row["斜率"] = "0";
                    }
                }
                //“”则存0
                else
                {
                    row["斜率"] = "0";
                }
                //电流幅值2
                if (tlSlopeStep.Nodes[i]["CurrAmp2"] != null)
                {
                    if (tlSlopeStep.Nodes[i]["CurrAmp2"].ToString() != "")
                    {
                        //不是默认单位则转换数据
                        if (cbxCurrent.Text != "A" && cbxCurrent.Text != "W")
                        {
                            row[strMode + "幅值2"] = ((float.Parse((tlSlopeStep.Nodes[i]["CurrAmp2"]).ToString())) * float.Parse(tbRate.Text) / 1000).ToString();
                        }
                        //默认单位直接存数据
                        else
                        {
                            row[strMode + "幅值2"] = float.Parse(tlSlopeStep.Nodes[i]["CurrAmp2"].ToString()) * float.Parse(tbRate.Text);
                        }
                    }
                    //“”则存0
                    else
                    {
                        row[strMode + "幅值2"] = "0";
                    }
                }
                //“”则存0
                else
                {
                    row[strMode + "幅值2"] = "0";
                }
                //时间
                if (tlSlopeStep.Nodes[i]["Time"] != null)
                {
                    if (tlSlopeStep.Nodes[i]["Time"].ToString() != "")
                    {
                        //不是默认单位则转换数据
                        if (cbxTime.SelectedItem.ToString() != "s")
                        {
                            row["时间"] = ((float.Parse(tlSlopeStep.Nodes[i]["Time"].ToString())) / 1000);
                        }
                        //默认单位直接存数据
                        else
                        {
                            row["时间"] = tlSlopeStep.Nodes[i]["Time"];
                        }
                    }
                    //“”则存0
                    else
                    {
                        row["时间"] = "0";
                    }
                }
                //“”则存0
                else
                {
                    row["时间"] = "0";
                }
                dt.Rows.Add(row);
            }
            return dt;
        }
        /// <summary>
        /// DataTable转treelist
        /// </summary>
        /// <param name="dt"></param>
        public void DtToTreeList(DataTable dt, string curOrPowUnit, string timeUnit)
        {
            int count = dt.Rows.Count;
            if (count > 0)
            {
                tlSlopeStep.Nodes.Clear();
                for (int i = 0; i < count; i++)
                {
                    TreeListNode tn = tlSlopeStep.Nodes.Add();//新增工步节点
                    tn["SerialNum"] = i + 1;
                    tn["Slope"] = dt.Rows[i][1];
                    if (curOrPowUnit == "mA" || curOrPowUnit == "mW")//标准值的千分之一的数值
                    {
                        tn["CurrAmp1"] = Convert.ToSingle(dt.Rows[i][0]) * 1000 / Convert.ToSingle(tbRate.Text);
                        tn["CurrAmp2"] = Convert.ToSingle(dt.Rows[i][2]) * 1000 / Convert.ToSingle(tbRate.Text);
                    }
                    else//标准单位下的数值
                    {
                        tn["CurrAmp1"] = Convert.ToSingle(dt.Rows[i][0]) / Convert.ToSingle(tbRate.Text);
                        tn["CurrAmp2"] = Convert.ToSingle(dt.Rows[i][0]) / Convert.ToSingle(tbRate.Text);
                    }
                    if (timeUnit == "ms")
                    {
                        tn["Time"] = Convert.ToSingle(dt.Rows[i][3]) * 1000;
                    }
                    else
                    {
                        tn["Time"] = dt.Rows[i][3];
                    } 
                }
                tlSlopeStep.FocusedNode = tlSlopeStep.Nodes[0];//光标聚焦到第一行
            }
        }

        private void cbxCurrent_SelectedIndexChanged(object sender, EventArgs e)
        {
            //列名根据单位的选择变化
            if (cbxMode.SelectedItem.ToString() == "电流")
            {
                if (cbxCurrent.SelectedItem.ToString() == "A")
                {
                    tlSlopeStep.Columns[1].Caption = ResourceCulture.GetString("lblCurrentText") + "1(A）";
                    tlSlopeStep.Columns[3].Caption = ResourceCulture.GetString("lblCurrentText") + "2(A）";
                }
                else if (cbxCurrent.SelectedItem.ToString() == "mA")
                {
                    tlSlopeStep.Columns[1].Caption = ResourceCulture.GetString("lblCurrentText") + "1(mA）";
                    tlSlopeStep.Columns[3].Caption = ResourceCulture.GetString("lblCurrentText") + "2(mA）";
                }
            }
            else if (cbxMode.SelectedItem.ToString() == "功率")
            {
                if (cbxCurrent.SelectedItem.ToString() == "W")
                {
                    tlSlopeStep.Columns[1].Caption = ResourceCulture.GetString("Power") + "1(W）";
                    tlSlopeStep.Columns[3].Caption = ResourceCulture.GetString("Power") + "1(W）";
                }
                else if (cbxCurrent.SelectedItem.ToString() == "mW")
                {
                    tlSlopeStep.Columns[1].Caption = ResourceCulture.GetString("Power") + "2(mW）";
                    tlSlopeStep.Columns[3].Caption = ResourceCulture.GetString("Power") + "2(mW）";
                }
            }
        }

        private void cbxTime_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbxTime.SelectedItem.ToString() == "s")
            {
                tlSlopeStep.Columns[4].Caption = ResourceCulture.GetString("Time") + "(s)";
            }
            else if (cbxTime.SelectedItem.ToString() == "ms")
            {
                tlSlopeStep.Columns[4].Caption = ResourceCulture.GetString("Time") + "(ms)";
            }
        }
        /// <summary>
        /// 值发生变化后触发的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tlSlopeStep_CellValueChanged(object sender, CellValueChangedEventArgs e)
        {
            if (Convert.ToInt32(e.Node["SerialNum"]) == tlSlopeStep.Nodes.Count)
            {
                TreeListNode tmpNode = tlSlopeStep.Nodes.Add();
                tmpNode["SerialNum"] = tlSlopeStep.Nodes.Count;
            }
        }
        /// <summary>
        /// 插入一行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsmiAdd_Click(object sender, EventArgs e)
        {
            int currentNum = Convert.ToInt32(currentNode["SerialNum"]);
            TreeListNode newNode = tlSlopeStep.Nodes.Add();
            newNode["SerialNum"] = currentNum;
            tlSlopeStep.SetNodeIndex(newNode, currentNum);
            ReconstructionSerialNum();
        }
        /// <summary>
        /// 删除一行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsmiDelete_Click(object sender, EventArgs e)
        {
            tlSlopeStep.DeleteNode(currentNode);
            ReconstructionSerialNum();
        }
        /// <summary>
        /// 重新排列序号
        /// </summary>
        private void ReconstructionSerialNum()
        {
            for (int i = 0; i < tlSlopeStep.Nodes.Count; i++)
            {
                tlSlopeStep.Nodes[i]["SerialNum"] = i + 1;
            }
        }
        /// <summary>
        /// 新增10行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddTen_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < 10; i++)
            {
                TreeListNode tmpNode = tlSlopeStep.Nodes.Add();
                tmpNode["SerialNum"] = tlSlopeStep.Nodes.Count;
            }
        }
        #region 国际化
        private void SlopeCondition_Load(object sender, EventArgs e)
        {
            ResourceCulture.SetCurrentCulture(IndexPage.language);
            this.SetResourceCulture();
        }
        /// <summary>
        /// 为当前页面内所有控件设置文本语种
        /// </summary>
        private void SetResourceCulture()
        {
            this.Text = ResourceCulture.GetString("SlopeStep");
            this.lblTime.Text = ResourceCulture.GetString("TimeUnit") + ":";
            this.lblMode.Text = ResourceCulture.GetString("ModeSelect") + ":";
            this.lblRate.Text = ResourceCulture.GetString("Rate") + ":";
            this.lblPath.Text = ResourceCulture.GetString("SlopeFilePath") + ":";
            this.btnBrowse.Text = ResourceCulture.GetString("Browse");
            this.btnAddTen.Text = ResourceCulture.GetString("BatchAdd");
            this.btnSave.Text = ResourceCulture.GetString("Save2");
            this.btnConfirm.Text = ResourceCulture.GetString("LoginOk");
            this.btnCancel.Text = ResourceCulture.GetString("LoginCancel");
            this.tlSerialNum.Caption = ResourceCulture.GetString("Index");
        }
        #endregion
    }
}
